//
//  UIBarButtonItem-Extension.swift
//  CBLearnDY
//
//  Created by ncimall on 2017/11/16.
//  Copyright © 2017年 ncimall. All rights reserved.
//

import Foundation
import UIKit

extension UIBarButtonItem {
    //  便利构造函数
    convenience init(imageName : String, highImageName : String = "", rect : CGRect) {
        let btn = UIButton.init()
        btn.setImage(UIImage.init(named: imageName), for: .normal)
        
        if highImageName != "" {
            btn.setImage(UIImage.init(named: highImageName), for: .highlighted)
        }
        
        if rect == CGRect.init(x: 0, y: 0, width: 0, height: 0) {
            btn.sizeToFit()
        } else {
            btn.frame = rect
        }
        
        self.init(customView: btn)
    }
}
